package com.voltmaon.shortlink.converter;

import java.io.IOException;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import cn.hutool.core.date.DatePattern;

public class JsonJodaDateTimeSerializer extends JsonSerializer<DateTime> {
	//    private static DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
	private static DateTimeFormatter formatter = DateTimeFormat.forPattern(DatePattern.NORM_DATETIME_MINUTE_PATTERN);

	@Override
	public void serialize(DateTime value, JsonGenerator gen, SerializerProvider arg2)
		throws IOException {
		gen.writeString(formatter.print(value));
	}
}